function loadJs(jspath){
    var script = document.createElement("script");
    script.type = "text/javascript";
    script.src = jspath;
    document.body.appendChild(script);
}
//退出
function logOut() {
    $.cookie("access_token","",{ expires: 365, path: '/' });
    $.cookie("search-projectId","",{ expires: 365, path: '/' });
    window.location.href="/sys/first";
}
function chk() {
    send(
        '/chkToken',
        {access_token:$.cookie("access_token")},
        function (data) {

        },
        function (res) {
            
        }
    );
}
//首页
function index() {
    window.location.href="/sys/index?access_token="+$.cookie("access_token");
}
//控制台
function console() {
    $("#mainDiv").load("/sys/center?access_token="+$.cookie("access_token"),"",function(response,status,xhr){
        //加载数据
        loadProjectError();
        if($("#search-projectId").val() != '' && $("#search-projectId").val() != null){
            loadCharts();
        }
        document.body.scrollTop = document.documentElement.scrollTop = 0;
    });
}
//图标插件
function loadCharts() {
    $('#t-projectName').text('【'+$("#search-projectId").find("option:selected").text()+'】');
    var chart = null;
    // $.getJSON('https://data.jianshukeji.com/jsonp?filename=json/usdeur.json&callback=?', function (data) {
    $.getJSON('/sys/loadChartData/'+$("#search-projectId").val(), function (data) {
        chart = Highcharts.chart('container', {
            chart: {
                zoomType: 'x'
            },
            title: {
                text:  '【'+$("#search-projectId").find("option:selected").text()+'】项目错误时间分布图'
            },
            subtitle: {
                text: document.ontouchstart === undefined ?
                    '鼠标拖动可以进行缩放' : '手势操作进行缩放'
            },
            xAxis: {
                type: 'datetime',
                dateTimeLabelFormats: {
                    millisecond: '%H:%M:%S.%L',
                    second: '%H:%M:%S',
                    minute: '%H:%M',
                    hour: '%H:%M',
                    day: '%m-%d',
                    week: '%m-%d',
                    month: '%Y-%m',
                    year: '%Y'
                }
            },
            tooltip: {
                dateTimeLabelFormats: {
                    millisecond: '%H:%M:%S.%L',
                    second: '%H:%M:%S',
                    minute: '%H:%M',
                    hour: '%H:%M',
                    day: '%Y-%m-%d',
                    week: '%m-%d',
                    month: '%Y-%m',
                    year: '%Y'
                }
            },
            yAxis: {
                title: {
                    text: '错误个数'
                }
            },
            legend: {
                enabled: false
            },
            plotOptions: {
                area: {
                    fillColor: {
                        linearGradient: {
                            x1: 0,
                            y1: 0,
                            x2: 0,
                            y2: 1
                        },
                        stops: [
                            [0, Highcharts.getOptions().colors[0]],
                            [1, Highcharts.Color(Highcharts.getOptions().colors[0]).setOpacity(0).get('rgba')]
                        ]
                    },
                    marker: {
                        radius: 2
                    },
                    lineWidth: 1,
                    states: {
                        hover: {
                            lineWidth: 1
                        }
                    },
                    threshold: null
                }
            },
            series: [{
                type: 'area',
                name: '错误个数',
                data: data
            }]
        });
    });
}
// 项目列表
function project_list() {
    $("#mainDiv").load("/sys/project_list","",function(response,status,xhr){
        //加载数据
        loadProject();
        document.body.scrollTop = document.documentElement.scrollTop = 0;
    });
}
//新建项目
function project_add() {
    $("#mainDiv").load("/sys/project_add","",function(response,status,xhr){
        document.body.scrollTop = document.documentElement.scrollTop = 0;
    });
}
//团队信息
function team_info() {
    $("#mainDiv").load("/sys/team_info?access_token="+$.cookie("access_token"),"",function(response,status,xhr){
        document.body.scrollTop = document.documentElement.scrollTop = 0;
    });
}
//成员管理
function member_management() {
    $("#mainDiv").load("/sys/member_management","",function(response,status,xhr){
        document.body.scrollTop = document.documentElement.scrollTop = 0;
    });
}
